﻿select 
	REFERENTIAL_CONSTRAINTS.CONSTRAINT_NAME,
	REFERENTIAL_CONSTRAINTS.TABLE_NAME,
	REFERENTIAL_CONSTRAINTS.UPDATE_RULE,
	REFERENTIAL_CONSTRAINTS.DELETE_RULE,
	REFERENTIAL_CONSTRAINTS.REFERENCED_TABLE_NAME,
	KEY_COLUMN_USAGE.COLUMN_NAME,
	KEY_COLUMN_USAGE.REFERENCED_COLUMN_NAME
from INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
inner join INFORMATION_SCHEMA.KEY_COLUMN_USAGE on REFERENTIAL_CONSTRAINTS.TABLE_NAME = KEY_COLUMN_USAGE.TABLE_NAME and REFERENTIAL_CONSTRAINTS.CONSTRAINT_NAME = KEY_COLUMN_USAGE.CONSTRAINT_NAME
where REFERENTIAL_CONSTRAINTS.CONSTRAINT_SCHEMA = '#DATABASE#' and REFERENTIAL_CONSTRAINTS.TABLE_NAME =[OBJECT_NAME_CONDITION]
order by KEY_COLUMN_USAGE.ORDINAL_POSITION
